﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace CQIE.LabAssist.Models.Migrations
{
    /// <inheritdoc />
    public partial class two : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Checks_TB_Laboratory_laboratoryId",
                table: "Checks");

            migrationBuilder.DropForeignKey(
                name: "FK_Checks_TB_Semester_semesterId",
                table: "Checks");

            migrationBuilder.DropForeignKey(
                name: "FK_TB_Building_Academicians_academicianId",
                table: "TB_Building");

            migrationBuilder.DropForeignKey(
                name: "FK_TB_User_Academicians_acadminianId",
                table: "TB_User");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Checks",
                table: "Checks");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Academicians",
                table: "Academicians");

            migrationBuilder.RenameTable(
                name: "Checks",
                newName: "TB_Check");

            migrationBuilder.RenameTable(
                name: "Academicians",
                newName: "TB_Academician");

            migrationBuilder.RenameIndex(
                name: "IX_Checks_semesterId",
                table: "TB_Check",
                newName: "IX_TB_Check_semesterId");

            migrationBuilder.RenameIndex(
                name: "IX_Checks_laboratoryId",
                table: "TB_Check",
                newName: "IX_TB_Check_laboratoryId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_TB_Check",
                table: "TB_Check",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_TB_Academician",
                table: "TB_Academician",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_TB_Building_TB_Academician_academicianId",
                table: "TB_Building",
                column: "academicianId",
                principalTable: "TB_Academician",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_TB_Check_TB_Laboratory_laboratoryId",
                table: "TB_Check",
                column: "laboratoryId",
                principalTable: "TB_Laboratory",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_TB_Check_TB_Semester_semesterId",
                table: "TB_Check",
                column: "semesterId",
                principalTable: "TB_Semester",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_TB_User_TB_Academician_acadminianId",
                table: "TB_User",
                column: "acadminianId",
                principalTable: "TB_Academician",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_TB_Building_TB_Academician_academicianId",
                table: "TB_Building");

            migrationBuilder.DropForeignKey(
                name: "FK_TB_Check_TB_Laboratory_laboratoryId",
                table: "TB_Check");

            migrationBuilder.DropForeignKey(
                name: "FK_TB_Check_TB_Semester_semesterId",
                table: "TB_Check");

            migrationBuilder.DropForeignKey(
                name: "FK_TB_User_TB_Academician_acadminianId",
                table: "TB_User");

            migrationBuilder.DropPrimaryKey(
                name: "PK_TB_Check",
                table: "TB_Check");

            migrationBuilder.DropPrimaryKey(
                name: "PK_TB_Academician",
                table: "TB_Academician");

            migrationBuilder.RenameTable(
                name: "TB_Check",
                newName: "Checks");

            migrationBuilder.RenameTable(
                name: "TB_Academician",
                newName: "Academicians");

            migrationBuilder.RenameIndex(
                name: "IX_TB_Check_semesterId",
                table: "Checks",
                newName: "IX_Checks_semesterId");

            migrationBuilder.RenameIndex(
                name: "IX_TB_Check_laboratoryId",
                table: "Checks",
                newName: "IX_Checks_laboratoryId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Checks",
                table: "Checks",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Academicians",
                table: "Academicians",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Checks_TB_Laboratory_laboratoryId",
                table: "Checks",
                column: "laboratoryId",
                principalTable: "TB_Laboratory",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Checks_TB_Semester_semesterId",
                table: "Checks",
                column: "semesterId",
                principalTable: "TB_Semester",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_TB_Building_Academicians_academicianId",
                table: "TB_Building",
                column: "academicianId",
                principalTable: "Academicians",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_TB_User_Academicians_acadminianId",
                table: "TB_User",
                column: "acadminianId",
                principalTable: "Academicians",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
